/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package business;

import model.Employee;
import model.EmployeeManager;

/**
 *
 * @author Administrator
 */
public class LoginCmd extends AbstractCommand {

    @Override
    public boolean execute(Object args) {
        EmployeeManager em = EmployeeManager.getInstance();
        Employee employee = em.getEmployeeById(id);
        if( employee == null )
            return false;
        if( !employee.getPwd().equals(password) )
            return false;
        em.setActivatedEmployee(employee);
        setLoginEmployee(employee);
        return true;
    }

 
    private String id;
    private String password;
    private Employee loginEmployee;
    
       /**
     * @return the id
     */
    public String getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(String id) {
        this.id = id;
    }

    /**
     * @return the password
     */
    public String getPassword() {
        return password;
    }

    /**
     * @param password the password to set
     */
    public void setPassword(String password) {
        this.password = password;
    }

    /**
     * @return the loginEmployee
     */
    public Employee getLoginEmployee() {
        return loginEmployee;
    }

    /**
     * @param loginEmployee the loginEmployee to set
     */
    public void setLoginEmployee(Employee loginEmployee) {
        this.loginEmployee = loginEmployee;
    }
}
